home *** CD-ROM | disk | FTP | other *** search
- package symantec.itools.db.pro;
-
- import java.util.Hashtable;
- import java.util.Properties;
- import java.util.Vector;
- import symantec.itools.db.net.Param;
- import symantec.itools.db.net.RemoteObject;
- import symantec.itools.db.net.SQLConnectionException;
- import symantec.itools.db.net.TextParam;
- import symjava.sql.SQLException;
-
- public class AutoDetail extends Request {
- public static final String ONE_TO_MANY = new String("1");
- public static final String ONE_TO_ONE = new String("2");
- public static final String MANY_TO_ONE = new String("3");
- public static final String MANY_TO_MANY = new String("4");
- private final int METHOD_execute;
- private final int METHOD_join = 2;
- private final int METHOD_setCardinality = 3;
- private final int METHOD_setOptimisticConcurrency = 7;
- private final int METHOD_setUserAndPassword = 9;
- private final int METHOD_getUserAndPassword = 10;
- private int _id;
- private RelationView _rv;
- protected RemoteObject _messgr;
- private int _paramIndex;
-
- public AutoDetail(RelationView rv, ConnectionInfo conn) {
- super(rv.getSession(), conn);
- this._rv = rv;
- this._id = 0;
- }
-
- public void join(int paramIndex, int resultCol) throws SQLException {
- Vector params = new Vector();
- params.addElement(new Param(0, paramIndex));
- params.addElement(new Param(0, resultCol));
- this.GetMessgr().invokeMethod(2, params);
- this.setParamIndex(paramIndex + 1);
- }
-
- public void join(int paramIndex, String resultColName) throws SQLException {
- this.join(paramIndex, this.getRelationView().findProjByName(resultColName));
- }
-
- public void join(String resultColName) throws SQLException {
- this.join(this.getParamIndex(), this.getRelationView().findProjByName(resultColName));
- }
-
- public void setDetailProperties(Properties detailProps) {
- this.transferProperties(detailProps);
- }
-
- public Properties getDetailProperties() {
- return this;
- }
-
- public RelationView executeRequest() throws SQLException {
- Vector results = this.getExecuteRequestResults();
- RelationView rView = new RelationView(super._sess, this._rv.getMultiView(), this._rv, results, this._rv.getMultiView().getNextLevelID(), ((Request)this).getConnectionInfo());
- this._rv.addDetailRelView(rView);
- if (((Request)this).getInitialRecordPos().equals(Request.REC_POS_FIRST)) {
- rView.first();
- } else if (((Request)this).getInitialRecordPos().equals(Request.REC_POS_NEW)) {
- rView.getNewRecord();
- }
-
- return rView;
- }
-
- Vector getExecuteRequestResults() throws SQLException {
- int retries = 0;
-
- while(true) {
- try {
- Vector params = new Vector();
- params.addElement(new TextParam(1, ((Request)this).getConnectionInfo().getDBString()));
- params.addElement(new TextParam(1, ((Request)this).getSQL()));
- params.addElement(new Param(1, ((Request)this).getOptConc()));
- params.addElement(new Param(1, 200));
- params.addElement(new TextParam(1, ((Request)this).getConnectionInfo().getUser()));
- params.addElement(new TextParam(1, ((Request)this).getConnectionInfo().getPassword()));
- params.addElement(new Param(1, this.getCardinality()));
- params.addElement(new Param(0, ((Request)this).getConnectionInfo().getAutoDisconnect()));
- Vector results = this.GetMessgr().invokeMethod(0, params);
- return results;
- } catch (SQLConnectionException e) {
- Session var10000 = super._sess;
- ConnectionInfo var10001 = ((Request)this).getConnectionInfo();
- ++retries;
- if (!var10000.logonFailed(var10001, retries)) {
- throw e;
- }
- }
- }
- }
-
- protected int getCardinality() {
- String value = ((Properties)this).getProperty("cardinality", ONE_TO_MANY);
- Integer i = Integer.valueOf(value);
- return i;
- }
-
- private void transferProperties(Properties newProps) {
- if (newProps == null) {
- ((Hashtable)this).put("cardinality", ONE_TO_MANY);
- } else {
- ((Hashtable)this).put("cardinality", newProps.getProperty("cardinality", ONE_TO_MANY));
- }
- }
-
- public void setCardinality(String setting) {
- if (setting.equals("One To One")) {
- ((Hashtable)this).put("recPosition", ONE_TO_ONE);
- } else if (setting.equals("One To Many")) {
- ((Hashtable)this).put("recPosition", ONE_TO_MANY);
- } else if (setting.equals("Many To Many")) {
- ((Hashtable)this).put("recPosition", MANY_TO_MANY);
- } else {
- ((Hashtable)this).put("recPosition", MANY_TO_ONE);
- }
- }
-
- RelationView getRelationView() {
- return this._rv;
- }
-
- protected RemoteObject GetMessgr() throws SQLException {
- if (this._messgr == null) {
- this._messgr = new RemoteObject("CSCLPreparedRelView", this.getID(), this.getRelationView().getSession().getClientSession());
- }
-
- return this._messgr;
- }
-
- int getID() throws SQLException {
- if (this._id == 0) {
- this._id = this.getRelationView().getAutoDetailMessgrID(((Request)this).getConnectionInfo(), ((Request)this).getSQL(), this, this);
- }
-
- return this._id;
- }
-
- private int getParamIndex() {
- return this._paramIndex;
- }
-
- private void setParamIndex(int paramIndex) {
- this._paramIndex = paramIndex;
- }
- }
-